<?php
/*
 * Copyright (C) 2009 Jeffrey Palm
 */

$events = readEvents('data.xml');

echo '<table class="schedule">';
echo '<tr>';
$days2abbrevs = array(
                      'Monday' => 'MON',
                      'Tuesday' => 'TUE',
                      'Wednesday' => 'WED',
                      'Thursday' => 'THU',
                      'Friday' => 'FRI',             
                      'Saturday' => 'SAT',
                      'Sunday' => 'SUN'
                      );
echo '<th>';
echo '</th>';
foreach ($days2abbrevs as $day => $abbrev) {
  echo '<th class="darker">';
  echo $day;
  echo '</th>';
}
echo '</tr>';

for ($i=0; $i<48; $i++) {
  echo '<tr>';
  echo '<td valign="top" class="darker">';
  $time = (int)($i/2) .'';
  $time .= ($i%2) == 0 ? '00' : '30';
  if ($time < 1000) {
    $time = '0' . $time;
  }
  echo '<b>' . $time . '</b>';
  echo '</td>';
  foreach ($days2abbrevs as $day => $abbrev) {
    echo '<td>';
    foreach ($events as $e) {
      if ($e->getDay() == $abbrev && $e->getTime() == $time) {
        echo $e->asHTML();
        echo '<br/>';
      }
    }
    echo '</td>';
  }
  echo '</tr>';
 }

echo '</table>';

?>